package com.alan.product.issue.util;

import com.alan.product.issue.entity.User;

public class UserContext {
    private static final ThreadLocal<UserContext> THREAD_LOCAL = ThreadLocal.withInitial(UserContext::new);

    private User user;

    public static void setUser(User user) {
        THREAD_LOCAL.get().user = user;
    }

    public static void removeUser() {
        THREAD_LOCAL.get().user = null;
    }

    public static User getUser() {
        return THREAD_LOCAL.get().user;
    }
}
